package grpc

import (
	"context"
	"time"

	"gitee.com/xgotool/sqlite-logs-more/protoc"
	"github.com/golang/protobuf/ptypes/empty"
)

// 获取设备详情信息
func (c *GrpcRemote) Info(cnt context.Context, em *empty.Empty) (*protoc.ClientInfo, error) {
	der, err := getDid(cnt)
	if err != nil {
		return nil, notFond(err)
	}
	if c.Dervice == nil {
		c.Dervice = der
	}
	return &protoc.ClientInfo{
		Id:             der.Id,
		Name:           der.Name,
		Desc:           der.Desc,
		HeartTime:      time.Unix(der.LastHart, 0).Format(time.DateTime),
		FirstLoginTime: time.Unix(der.Id/1e9, 0).Format(time.DateTime),
	}, nil
	// return nil, status.Errorf(codes.Unimplemented, "method Info not implemented")
}
